({
    TableModel: {
        "model": {
            "Id": 0,
            "BookName": "",
            "BuyPrice": "",
            "BuyDate": "yyyy-MM-dd HH:mm:ss",
            "Flag": 0,
            "WorkId": 1
        },
        "tablename": "Books",
        "key": "Id",
        "val": "0",
        "objval": {},
        "query": {
            "BookName": "like"
        },
        "where": "",
        "pageinfo": {},
        "WorkId": 1
    },
    data: {
        dbConn: null
    },
    main:function(){
        this.data.dbConn=TSLobsterAPI.Program.GetDbConn();
    },
    getdata: function () {

        var self = this;
        var pageInfo = {};
        pageInfo.key = "Id";
        pageInfo.page = TSLobsterAPI.Program.RequestQuery("page", 1);
        pageInfo.perPage = TSLobsterAPI.Program.RequestQuery("perPage", 10);
        pageInfo.totalRecord = 100;

        self.TableModel.where = TSLobsterAPI.DbHelper.GetWhere(self.TableModel.query);
        self.TableModel.pageinfo = pageInfo;

        var datagrid = { "items": [], "total": 200 };
        datagrid.items = TSLobsterAPI.DbHelper.GetListModelPage(self.data.dbConn, self.TableModel);
        datagrid.total = pageInfo.totalRecord;

        return datagrid;
    },
    savemodel: function () {
        var self = this;
        self.TableModel.WorkId = TSLobsterAPI.Program.GetWorkId(); //机构ID
        self.TableModel.objval = JSON.parse(TSLobsterAPI.Program.RequestBody());
        TSLobsterAPI.DbHelper.SaveModel(self.data.dbConn, self.TableModel);
        return { result: true };
    },
    deletemodel: function () {
        var self = this;
        self.TableModel.val = TSLobsterAPI.Program.RequestQuery("Id", 0);
        TSLobsterAPI.DbHelper.DeleteModel(self.data.dbConn, self.TableModel);
        return { result: true };
    }
})